<?php
namespace Admin\Controller;
class ZhaobiaoController extends IsloginController{
	function oper(){

        if(!isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"])=="xmlhttprequest"){
//            $this->seach();
//            $this->schaxun();
//            $this->shchaxun();
        }else{
            $biao = M("Biao");
            $num=$biao->count();
// 		3、规定每页显示的条数
            $pageSize=8;
// 		4、实例化分页类
            $pageOb=new \Think\Page($num,$pageSize);
// 		5、获取开始位置值
            $start=$pageOb->firstRow;
// 		6、获取分页结果
            $pageStr=$pageOb->show();
            $arr = $biao->limit("$start,$pageSize")->select();
            $this->assign('pageStr',$pageStr);
            $this->assign('arr',$arr);
            $this->show();
        }


	}
	function update(){
		$biao = M("Biao");
		$id=$_GET['id'];	
		$arr = $biao->where("id=$id")->find();
		$this->assign('arr',$arr);
		$this->display();
	}
	function save(){
		$xiugai = M('Biao');
		$_POST['shtime']=time();
		$re = $xiugai->data($_POST)->save();
		if($re){
			$this->success("修改成功",U("Zhaobiao/oper"));
		}else{
			$this->error("修改失败");
		}
	}
	function fabu(){
		$this->show();
	}
	function add(){
		$zhaobiao = M("Biao");
		$_POST['addtime']=time();
		$_POST['ip']=get_client_ip();
		$re = $zhaobiao->data($_POST)->add();
		if($re){
			echo "添加成功！";
		}else{
			echo "添加失败！";
		}
	}
	function del(){
		$biao = M("Biao");
		$id=$_POST['id'];	
		$re = $biao->where("id=$id")->delete();
		if($re){
			$this->success("删除成功",U("Zhaobiao/oper"));
		}else{
			$this->error("删除失败",U("Zhaobiao/oper"));
		}
	}
	function seach(){
        if(isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"])=="xmlhttprequest") {
            $biao = M("Biao");
            $_county = $_POST["s_county"];
            $county = $biao->where("s_county='$_county'")->select();
            $this->ajaxReturn($county);
            var_dump($county);

        }
	}
	function schaxun(){
        if(isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"])=="xmlhttprequest") {
            $biao = M("Biao");
            $bid = $_POST["bstatus"];
            $zhongbiao = $biao->where("bstatus=$bid")->select();
           echo json_encode($zhongbiao);

        }
    }
    function shchaxun(){
        if(isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"])=="xmlhttprequest") {
            $biao = M("Biao");
            $shid = $_POST["shstatus"];
            $sh = $biao->where("shstatus=$shid")->select();
            $this->ajaxReturn($sh);

        }
    }
    function seachs(){
        if(isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"])=="xmlhttprequest") {
            $biao = M("Biao");
            $con = $_POST['keyword'];
            $data['comm|shstatus|bstatus|s_county|s_province|s_city'] = array('like', "%$con%");
            $shs = $biao->where($data)->select();
            $this->ajaxReturn($shs);
        }
    }

}